<?php

namespace App\Http\Controllers;

use App\User;
use App\Qd;
use Illuminate\Http\Request;


class UserC extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Login
     */

    public function Dl()
    {
        include "Connect2.1\API\qqConnectAPI.php";
        $Q = new \QC();
        return $Q->qq_login();
    }

    public function Dls()
    {
        include "Connect2.1\API\qqConnectAPI.php";
        $Q = new \QC();
        $accen_tocken  = $Q->qq_callback();
        $open_id = $Q->get_openid();
        $pc = new \QC($accen_tocken, $open_id);
        $data = $pc->get_user_info();



        if (isset($data['nickname'])) {
            $model = new Qd();
            $arr = $model->adds($open_id);

            if (isset($arr)) {
                return view('User.BT', ['pid' => $arr]);
            }
        } else {
            return ['code' => 1, 'code' => 'ERROR!!!', 'data' => ''];
        }
    }




    /**
     * Code
     */
    public function F(Request $request)
    {
        $this->validate($request, [
            'tel' => 'required',
        ]);

        $res = Qd::F($request);
        if ($res) {
            return ['code' => 0, 'code' => 'SUCCESS!!!', 'data' => ''];
        } else {
            return ['code' => 1, 'code' => 'ERROR!!!', 'data' => ''];
        }
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\User  $user
     * @return \Illuminate\Http\Response
     */
    public function show(User $user)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\User  $user
     * @return \Illuminate\Http\Response
     */
    public function edit(User $user)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\User  $user
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, User $user)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\User  $user
     * @return \Illuminate\Http\Response
     */
    public function destroy(User $user)
    {
        //
    }
}
